<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Quiz
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: _header.tpl 2010-07-02 17:53 michael $
 * @author     Michael
 */


$this->headScript()
    ->appendFile($this->baseUrl() . '/application/modules/Wall/externals/scripts/core.js')
    ->appendFile($this->baseUrl() . '/externals/moolasso/Lasso.js')
    ->appendFile($this->baseUrl() . '/externals/moolasso/Lasso.Crop.js')
    ->appendFile($this->baseUrl() . '/externals/autocompleter/Observer.js')
    ->appendFile($this->baseUrl() . '/externals/autocompleter/Autocompleter.js')
    ->appendFile($this->baseUrl() . '/externals/autocompleter/Autocompleter.Local.js')
    ->appendFile($this->baseUrl() . '/externals/autocompleter/Autocompleter.Request.js')
    ->appendFile($this->baseUrl() . '/externals/tagger/tagger.js')
    ->appendFile($this->baseUrl() . '/application/modules/Wall/externals/webcam/webcam.js');

$translate_list = array(
  'WALL_CONFIRM_ACTION_REMOVE_TITLE',
  'WALL_CONFIRM_ACTION_REMOVE_DESCRIPTION',
  'WALL_CONFIRM_COMMENT_REMOVE_TITLE',
  'WALL_CONFIRM_COMMENT_REMOVE_DESCRIPTION',
  'WALL_CONFIRM_LIST_REMOVE_TITLE',
  'WALL_CONFIRM_LIST_REMOVE_DESCRIPTION',
  'WALL_LIKE',
  'WALL_UNLIKE',
  'Save',
  'Cancel',
  'delete',
  'WALL_LOADING',
  'WALL_STREAM_EMPTY_VIEWALL',
  'WALL_EMPTY_FEED',
  'WALL_CAMERA_FREEZE',
  'WALL_CAMERA_CANCEL',
  'WALL_CAMERA_UPLOAD',
  'WALL_COMPOSE_CAMERA'
);


$services = array_keys(Engine_Api::_()->wall()->getManifestType('wall_service'));

foreach ($services as $service){
  $translate_list[] = 'WALL_SHARE_' . strtoupper($service) . '';
  $translate_list[] = 'WALL_SHARE_' . strtoupper($service) . '_ACTIVE';
  $translate_list[] = 'WALL_STREAM_' . strtoupper($service) . '_LOGIN';
}

$this->headTranslate($translate_list);


?>

<script type="text/javascript">

  Wall.runonce.add(function (){

<?php
    
  if ($this->viewer()->getIdentity()){

    foreach ($services as $service){
      $class = Engine_Api::_()->wall()->getServiceClass($service);
      if (!$class){
        continue ;
      }
      $tokenRow = Engine_Api::_()->getDbTable('tokens', 'wall')->getUserToken($this->viewer(), $service);
      if ($tokenRow){
        $enabled = $class->check($tokenRow);
        $config = array(
          'provider' => $service,
          'enabled' => $enabled
        );
        $config = array_merge($config, $tokenRow->publicArray());
      } else {
        $config = array(
          'provider' => $service,
          'enabled' => false
        );
      }

      echo 'Wall.services.add("'.$service.'", new Wall.Service.'.ucfirst($service).'('.$this->jsonInline($config).'));';
    }
  }

?>


  });

</script>
